import Router from 'koa-router'

const { entIdExist } = require('../middleware/ents.middleware')
const { auth } = require('../middleware/auth.middleware')
const { getEnts, getEntsByname, getById, addEnt, updateEnt, deleteEnt, exportExcel, importExcel } = require('../controller/ents.controller') 
const router = new Router({ prefix: '/orgs/ents' })

/**
 * 企业管理模块
 * @description orgs
 */
router.get('/', getEnts) // 获取所有企业(分页可选)
router.get('/byName', getEntsByname) // 根据名字搜索企业(分页可选)
router.get('/exportExcel', exportExcel) // 导出Excel
router.get('/:id', entIdExist, getById) // 根据id获取企业
router.post('/', auth, addEnt) // 添加企业
router.post('/importExcel', auth, importExcel) // 导入Excel企业
router.put('/:id', auth, entIdExist, updateEnt) // 更新企业
router.delete('/:id', auth, entIdExist, deleteEnt) // 删除企业

module.exports = router